const key = ['battcell','canudp','signal']
const data = {
    "battcell": {
        "start": "1731495157807",
        "end": "0"
    },
    "canudp": {
        "start": "1731495207802",
        "end": "0"
    },
    "signal": {
        "start": "0",
        "end": "1731495207802"
    },
    "batttsnsr": {
        "start": "1731552587000",
        "end": "0"
    }
};


const matchedData = key.reduce((acc, curr) => {
    if (data.hasOwnProperty(curr)) {
      acc[curr] = { ...data[curr] };
    }
    return acc;
  }, {});

console.log(matchedData,'matchedData');
// 提取每个对象的 start 时间戳，并找出最早的时间戳
const startTimes = Object.values(data).map(item => parseInt(item.start, 10));

// 过滤掉无效的时间戳（例如，'0' 转换为数字后是 0）
const validStartTimes = startTimes.filter(item => item !== 0 && !isNaN(item));

// 使用 Math.min 找出最早的时间戳
const earliestStartTime = validStartTimes.length > 0 ? Math.min(...validStartTimes) : null;

console.log(earliestStartTime, 'earliestStartTime'); // 应该返回 

// 1731495157807 2024-11-13 18:52:37
// 1731495207802 2024-11-13 18:53:27
// 1731552587000  2024-11-14 10:49:47